﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using Kaskelot.SP.Services;
using Kaskelot.Web.ClientModel;
using Kaskelot.Web.Services;
using Stockholm.SOA.Kaskelot.WCF.DataContracts;

namespace Kaskelot.Web.ClientServices
{
	[ServiceContract(Namespace = "http://stockholm.se/Client/Kaskelot/ClientServices/", Name = "ClientValService")]
	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
	public class ClientValService
	{
		[OperationContract]
		[WebGet(BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
		public ClientServiceResult<string> GetValNamn()
		{
			ClientServiceResult<string> csr = new ClientServiceResult<string>();

			try
			{
				using (WebService svc = new WebService())
				{
					Val v = svc.GetVal(null);

					csr.Data = v.Namn;
					csr.ErrorMessage = String.Empty;
					csr.HasError = false;
				}
			}
			catch (Exception ex)
			{
				csr.ErrorMessage = ex.Message;
				csr.HasError = true;
			}

			return csr;
		}
	}
}